//
//  ViewController.m
//  TestCollectionView
//
//  Created by sunshinfight@163.com on 2019/4/17.
//  Copyright © 2019 sunshinfight@163.com. All rights reserved.
//

#import "ViewController.h"
#import "JXCalendarView.h"
#import "JXCalendarViewController/JXCalendarViewController.h"

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self testPrintf];
}
- (IBAction)showCalendarButtonClicked:(id)sender {
    JXCalendarViewController *vc = [JXCalendarViewController new];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    
    [self presentViewController:nav animated:YES completion:nil];
}


//根据date获取偏移指定天数的date
- (NSDate *)getDateFrom:(NSDate *)date offsetDays:(NSInteger)offsetDays {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM"];
    
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *lastMonthComps = [[NSDateComponents alloc] init];
    [lastMonthComps setDay:offsetDays];  //year = 1表示1年后的时间 year = -1为1年前的日期，month day 类推
    NSDate *newdate = [calendar dateByAddingComponents:lastMonthComps toDate:date options:0];
    return newdate;
}

- (void)testCalendar
{
//    NSArray *dates = [BKACalendarUtils datesWithStartYear:2018 endYear:2019];
//    NSInteger year = [BKACalendarUtils yearWithDate:dates.firstObject];
//    NSInteger day = [BKACalendarUtils dayWithDate:dates.firstObject];
//    NSLog(@"");
}

- (void)testPrintf {
    printf("三位整数，不足前面补0：%03d", 12);
    printf("三位小数，2位证书：%04.1f", 4.1);
}

@end
